Skip to content

Comments

Update --base-url recipe docs, and add warning box#138

Merged
mre merged 3 commits intolycheeverse:masterfrom
rina-forks:base-url-update-2
Feb 7, 2026
Merged

Update --base-url recipe docs, and add warning box#138
mre merged 3 commits intolycheeverse:masterfrom
rina-forks:base-url-update-2

Conversation

@katrinafyi
Copy link
Member

The goal is to add more detail where I can, and to remove information which I think is no longer correct. I think this page was originally written when --base-url behaved quite differently (before --root-dir?).

I've left all of the examples even though I think they will not work. The examples are all very brief so I don't know what they're intended to show. I've left them to be safe.

The statements which I've removed or changed because I think they're no longer correct are:

Even though your site isn't deployed yet, lychee can verify that the
files your links point to exist in your project.

The --base-url parameter works similarly to other tools you might know:

--base-url: Use it when you care about your site's final URL structure

Also don't recommend using both --root-dir and --base-url.

The goal is to add more detail where I can, and to remove information
which I think is no longer correct. I think this page was originally
written when --base-url behaved quite differently (before --root-dir?).

I've left all of the examples even though I think they will not work.
The examples are all very brief so I don't know what they're intended
to show. I've left them to be safe.

The statements which I've removed or changed because I think they're no
longer correct are:

> Even though your site isn't deployed yet, lychee can verify that the
> files your links point to exist in your project.

>  The `--base-url` parameter works similarly to other tools you might know:

> --base-url: Use it when you care about your site's final URL structure

- You're only checking fully-qualified URLs.
- Your site runs at a root domain like `example.com`.
- Your relative links should resolve to other local files based on their folder structure.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "other" suggests that we check a file in the first place. It could be an online URL, though, so it's slightly confusing.

Suggested change
- Your relative links should resolve to other local files based on their folder structure.
- Your relative links should resolve to local files based on your folder structure.

Comment on lines +33 to +35
[--root-dir](/recipes/root-dir/) may be useful instead. Setting a root
directory can help to resolve absolute links, and relative links will be
resolved based on a local file's path.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That bit about resolving absolute links is also a bit confusing.
I think we need to be super clear with our wording here as I already caused too much trouble by being imprecise in the past. 😉

Unfortunately, I don't know how to phrase it better.

Suggested change
[--root-dir](/recipes/root-dir/) may be useful instead. Setting a root
directory can help to resolve absolute links, and relative links will be
resolved based on a local file's path.
[--root-dir](/recipes/root-dir/) may be useful instead. If you set a root
directory, absolute links will be resolved (what should we put here?), and relative links will be
resolved based on a local file's path relative to the root directory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

choosing to leave this for now

lychee --base-url https://example.com/docs/ --root-dir $(pwd)/public/ "public/**/*.html"
```
- [`--root-dir`](/recipes/root-dir) requires a local folder path (like `./public/`), and it:
- Applies to links with absolute paths (links beginning with `/`) in local files.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Applies to links with absolute paths (links beginning with `/`) in local files.
- Only applies to links with absolute paths (e.g. links beginning with `/` on Unix or `C:\` on Windows) in local files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is using the URL notion of absolute links, so it's those beginning with /. I should avoid the word "path" to avoid confusion.

```
- [`--root-dir`](/recipes/root-dir) requires a local folder path (like `./public/`), and it:
- Applies to links with absolute paths (links beginning with `/`) in local files.
- Resolves absolute links to files within the given root directory.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this can be a bit counterintuitive ("why doesn't it just check /foo and instead prefixes it with a 'root directory'?"), maybe we should add an example here.

Suggested change
- Resolves absolute links to files within the given root directory.
- Resolves absolute links to files within the given root directory.
For example, if lychee finds a link to `/contact` in your input and the root directory is set to `/usr/lychee/site`, then it will check `/usr/lychee/site/contact`.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

choosing to leave this for now. I also think root-dir has enough examples on the root dir page, which is linked.

@mre
Copy link
Member

mre commented Jan 8, 2026

Apart from some minor changes (see the comments), I don't see any blockers for merging this. But I'd be fine to merge it as-is as well. @katrinafyi, let me know your preference. 😉

@katrinafyi
Copy link
Member Author

I did mean to address the comments and I'd still like to.

It's just been low priority because it's documenting something which i think is a bit broken.

@mre
Copy link
Member

mre commented Jan 8, 2026

Ah yeah, all good. And yes, it's quite broken indeed. 😅 Somehow I wish I never introduced root-dir and base-url at all, or at least did so after doing a lot more research. Too late now, but here's hoping that we can fix some of the more gnarly edge cases in the future.

@mre
Copy link
Member

mre commented Feb 4, 2026

Merging this would be an improvement in my book. Shall we just do that? @katrinafyi, wdyt?

@katrinafyi
Copy link
Member Author

Yeah I agree. I'll try to remember to fix the more pressing comments in a follow up PR. Sorry for the delay :)

katrinafyi and others added 2 commits February 5, 2026 18:20
Co-authored-by: Matthias Endler <matthias@endler.dev>
Copy link
Member Author

@katrinafyi katrinafyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some changes and commented on the outstanding review comments

Comment on lines +33 to +35
[--root-dir](/recipes/root-dir/) may be useful instead. Setting a root
directory can help to resolve absolute links, and relative links will be
resolved based on a local file's path.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

choosing to leave this for now

```
- [`--root-dir`](/recipes/root-dir) requires a local folder path (like `./public/`), and it:
- Applies to links with absolute paths (links beginning with `/`) in local files.
- Resolves absolute links to files within the given root directory.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

choosing to leave this for now. I also think root-dir has enough examples on the root dir page, which is linked.

@mre mre merged commit d613126 into lycheeverse:master Feb 7, 2026
2 checks passed
@mre
Copy link
Member

mre commented Feb 7, 2026

Thanks for working on this. Another step towards saner documentation for those options. Keep it up! ✌️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants